package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyMessageBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class MessageAdapter extends StkProviderMultiAdapter<MyMessageBean> {

    public MessageAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new MessageProvider());
    }

    private class MessageProvider extends BaseItemProvider<MyMessageBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_message;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyMessageBean bean) {
            baseViewHolder.setText(R.id.tvMessageItemTime, bean.getTime());
            baseViewHolder.setText(R.id.tvMessageItemContent, bean.getMessage());
            if (bean.getType() == 0) {
                baseViewHolder.setTextColor(R.id.tvMessageItemContent, Color.parseColor("#181818"));
            } else if (bean.getType() == 1) {
                baseViewHolder.setTextColor(R.id.tvMessageItemContent, Color.parseColor("#1FAD3A"));
            } else if (bean.getType() == 2) {
                baseViewHolder.setTextColor(R.id.tvMessageItemContent, Color.parseColor("#3B5DE6"));
            }
        }
    }
}
